home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / AIncludes / Threads.a < prev    next >
Encoding:
Text File  |  1996-01-24  |  8.5 KB  |  391 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        Threads.a
  3. ;
  4. ;    Contains:    Thread Manager Interfaces.
  5. ;
  6. ;    Version:    Technology:    System 7.5
  7. ;                Package:    Universal Interfaces 2.2 in “MPW” on ETO #20
  8. ;
  9. ;    Copyright:    © 1984-1995 by Apple Computer, Inc.
  10. ;                All rights reserved.
  11. ;
  12. ;    Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13. ;                stack.  Include the file and version information (from above)
  14. ;                in the problem description and send to:
  15. ;                    Internet:    apple.bugs@applelink.apple.com
  16. ;                    AppleLink:    APPLE.BUGS
  17. ;
  18. ;
  19.  
  20.     IF &TYPE('__THREADS__') = 'UNDEFINED' THEN
  21. __THREADS__ SET 1
  22.  
  23.  
  24.     IF &TYPE('__ERRORS__') = 'UNDEFINED' THEN
  25.     include 'Errors.a'
  26.     ENDIF
  27. ;        include 'ConditionalMacros.a'                                ;
  28.  
  29.     IF &TYPE('__MEMORY__') = 'UNDEFINED' THEN
  30.     include 'Memory.a'
  31.     ENDIF
  32. ;        include 'Types.a'                                            ;
  33. ;        include 'MixedMode.a'                                        ;
  34. ; typedef unsigned short     ThreadState
  35.  
  36. kReadyThreadState                EQU        0
  37. kStoppedThreadState                EQU        1
  38. kRunningThreadState                EQU        2
  39.  
  40. ; Error codes have been meoved to Errors.(pah) 
  41. ; Thread environment characteristics 
  42. ; typedef void                 *ThreadTaskRef
  43. ; Thread characteristics 
  44. ; typedef unsigned long     ThreadStyle
  45.  
  46. kCooperativeThread                EQU        1 << 0
  47. kPreemptiveThread                EQU        1 << 1
  48.  
  49. ; Thread identifiers 
  50. ; typedef unsigned long     ThreadID
  51.  
  52. kNoThreadID                        EQU        0
  53. kCurrentThreadID                EQU        1
  54. kApplicationThreadID            EQU        2
  55.  
  56. ; Options when creating a thread 
  57. ; typedef unsigned long     ThreadOptions
  58.  
  59. kNewSuspend                        EQU        (1 << 0)
  60. kUsePremadeThread                EQU        (1 << 1)
  61. kCreateIfNeeded                    EQU        (1 << 2)
  62. kFPUNotNeeded                    EQU        (1 << 3)
  63. kExactMatchThread                EQU        (1 << 4)
  64.  
  65. ; Information supplied to the custom scheduler 
  66. SchedulerInfoRec         RECORD    0
  67. InfoRecSize                 ds.l   1        ; offset: $0 (0)
  68. CurrentThreadID             ds.l   1        ; offset: $4 (4)
  69. SuggestedThreadID         ds.l   1        ; offset: $8 (8)
  70. InterruptedCoopThreadID     ds.l   1        ; offset: $C (12)
  71. sizeof                     EQU *            ; size:   $10 (16)
  72.                         ENDR
  73.  
  74. ; typedef struct SchedulerInfoRec  SchedulerInfoRec
  75. ; typedef SchedulerInfoRec     *SchedulerInfoRecPtr
  76.     IF GENERATING68K  ** GENERATINGCFM  THEN
  77. ;
  78. ;    The following UniversalProcPtrs are for CFM-68k compatiblity with
  79. ;    the implementation of the Thread Manager.
  80. ;
  81. ; typedef UniversalProcPtr     ThreadEntryProcPtr
  82. ; typedef UniversalProcPtr     ThreadSchedulerProcPtr
  83. ; typedef UniversalProcPtr     ThreadSwitchProcPtr
  84. ; typedef UniversalProcPtr     ThreadTerminationProcPtr
  85. ; typedef UniversalProcPtr     DebuggerNewThreadProcPtr
  86. ; typedef UniversalProcPtr     DebuggerDisposeThreadProcPtr
  87. ; typedef UniversalProcPtr     DebuggerThreadSchedulerProcPtr
  88.     ELSE
  89. ;
  90. ;    The following ProcPtrs cannot be interchanged with UniversalProcPtrs because
  91. ;    of differences between 680x0 and PowerPC runtime architectures with regard to
  92. ;    the implementation of the Thread Manager.
  93. ; Prototype for thread's entry (main) routine 
  94. ; typedef void                 *voidPtr
  95. ; Prototype for custom thread scheduler routine 
  96. ; Prototype for custom thread switcher routine 
  97. ; Prototype for thread termination notification routine 
  98. ; Prototype for debugger NewThread notification 
  99. ; Prototype for debugger DisposeThread notification 
  100. ; Prototype for debugger schedule notification 
  101.     ENDIF
  102. ;
  103. ; pascal OSErr CreateThreadPool(ThreadStyle threadStyle, short numToCreate, Size stackSize)
  104. ;
  105.     IF ¬ GENERATINGCFM THEN
  106.         Macro
  107.         _CreateThreadPool
  108.             move.w    #$0501,d0
  109.             dc.w     $ABF2
  110.         EndM
  111.     ELSE
  112.         IMPORT_CFM_FUNCTION    CreateThreadPool
  113.     ENDIF
  114.  
  115. ;
  116. ; pascal OSErr GetFreeThreadCount(ThreadStyle threadStyle, short *freeCount)
  117. ;
  118.     IF ¬ GENERATINGCFM THEN
  119.         Macro
  120.         _GetFreeThreadCount
  121.             move.w    #$0402,d0
  122.             dc.w     $ABF2
  123.         EndM
  124.     ELSE
  125.         IMPORT_CFM_FUNCTION    GetFreeThreadCount
  126.     ENDIF
  127.  
  128. ;
  129. ; pascal OSErr GetSpecificFreeThreadCount(ThreadStyle threadStyle, Size stackSize, short *freeCount)
  130. ;
  131.     IF ¬ GENERATINGCFM THEN
  132.         Macro
  133.         _GetSpecificFreeThreadCount
  134.             move.w    #$0615,d0
  135.             dc.w     $ABF2
  136.         EndM
  137.     ELSE
  138.         IMPORT_CFM_FUNCTION    GetSpecificFreeThreadCount
  139.     ENDIF
  140.  
  141. ;
  142. ; pascal OSErr GetDefaultThreadStackSize(ThreadStyle threadStyle, Size *stackSize)
  143. ;
  144.     IF ¬ GENERATINGCFM THEN
  145.         Macro
  146.         _GetDefaultThreadStackSize
  147.             move.w    #$0413,d0
  148.             dc.w     $ABF2
  149.         EndM
  150.     ELSE
  151.         IMPORT_CFM_FUNCTION    GetDefaultThreadStackSize
  152.     ENDIF
  153.  
  154. ;
  155. ; pascal OSErr ThreadCurrentStackSpace(ThreadID thread, unsigned long *freeStack)
  156. ;
  157.     IF ¬ GENERATINGCFM THEN
  158.         Macro
  159.         _ThreadCurrentStackSpace
  160.             move.w    #$0414,d0
  161.             dc.w     $ABF2
  162.         EndM
  163.     ELSE
  164.         IMPORT_CFM_FUNCTION    ThreadCurrentStackSpace
  165.     ENDIF
  166.  
  167. ;
  168. ; pascal OSErr NewThread(ThreadStyle threadStyle, ThreadEntryProcPtr threadEntry, void *threadParam, Size stackSize, ThreadOptions options, void **threadResult, ThreadID *threadMade)
  169. ;
  170.     IF ¬ GENERATINGCFM THEN
  171.         Macro
  172.         _NewThread
  173.             move.w    #$0E03,d0
  174.             dc.w     $ABF2
  175.         EndM
  176.     ELSE
  177.         IMPORT_CFM_FUNCTION    NewThread
  178.     ENDIF
  179.  
  180. ;
  181. ; pascal OSErr DisposeThread(ThreadID threadToDump, void *threadResult, Boolean recycleThread)
  182. ;
  183.     IF ¬ GENERATINGCFM THEN
  184.         Macro
  185.         _DisposeThread
  186.             move.w    #$0504,d0
  187.             dc.w     $ABF2
  188.         EndM
  189.     ELSE
  190.         IMPORT_CFM_FUNCTION    DisposeThread
  191.     ENDIF
  192.  
  193. ;
  194. ; pascal OSErr YieldToThread(ThreadID suggestedThread)
  195. ;
  196.     IF ¬ GENERATINGCFM THEN
  197.         Macro
  198.         _YieldToThread
  199.             move.w    #$0205,d0
  200.             dc.w     $ABF2
  201.         EndM
  202.     ELSE
  203.         IMPORT_CFM_FUNCTION    YieldToThread
  204.     ENDIF
  205.  
  206. ;
  207. ; pascal OSErr YieldToAnyThread(void)
  208. ;
  209.     IF ¬ GENERATINGCFM THEN
  210.         Macro
  211.         _YieldToAnyThread
  212.             dc.w     $42A7
  213.             move.w    #$0205,d0
  214.             dc.w     $ABF2
  215.         EndM
  216.     ELSE
  217.         IMPORT_CFM_FUNCTION    YieldToAnyThread
  218.     ENDIF
  219.  
  220. ;
  221. ; pascal OSErr GetCurrentThread(ThreadID *currentThreadID)
  222. ;
  223.     IF ¬ GENERATINGCFM THEN
  224.         Macro
  225.         _GetCurrentThread
  226.             move.w    #$0206,d0
  227.             dc.w     $ABF2
  228.         EndM
  229.     ELSE
  230.         IMPORT_CFM_FUNCTION    GetCurrentThread
  231.     ENDIF
  232.  
  233. ;
  234. ; pascal OSErr GetThreadState(ThreadID threadToGet, ThreadState *threadState)
  235. ;
  236.     IF ¬ GENERATINGCFM THEN
  237.         Macro
  238.         _GetThreadState
  239.             move.w    #$0407,d0
  240.             dc.w     $ABF2
  241.         EndM
  242.     ELSE
  243.         IMPORT_CFM_FUNCTION    GetThreadState
  244.     ENDIF
  245.  
  246. ;
  247. ; pascal OSErr SetThreadState(ThreadID threadToSet, ThreadState newState, ThreadID suggestedThread)
  248. ;
  249.     IF ¬ GENERATINGCFM THEN
  250.         Macro
  251.         _SetThreadState
  252.             move.w    #$0508,d0
  253.             dc.w     $ABF2
  254.         EndM
  255.     ELSE
  256.         IMPORT_CFM_FUNCTION    SetThreadState
  257.     ENDIF
  258.  
  259. ;
  260. ; pascal OSErr SetThreadStateEndCritical(ThreadID threadToSet, ThreadState newState, ThreadID suggestedThread)
  261. ;
  262.     IF ¬ GENERATINGCFM THEN
  263.         Macro
  264.         _SetThreadStateEndCritical
  265.             move.w    #$0512,d0
  266.             dc.w     $ABF2
  267.         EndM
  268.     ELSE
  269.         IMPORT_CFM_FUNCTION    SetThreadStateEndCritical
  270.     ENDIF
  271.  
  272. ;
  273. ; pascal OSErr SetThreadScheduler(ThreadSchedulerProcPtr threadScheduler)
  274. ;
  275.     IF ¬ GENERATINGCFM THEN
  276.         Macro
  277.         _SetThreadScheduler
  278.             move.w    #$0209,d0
  279.             dc.w     $ABF2
  280.         EndM
  281.     ELSE
  282.         IMPORT_CFM_FUNCTION    SetThreadScheduler
  283.     ENDIF
  284.  
  285. ;
  286. ; pascal OSErr SetThreadSwitcher(ThreadID thread, ThreadSwitchProcPtr threadSwitcher, void *switchProcParam, Boolean inOrOut)
  287. ;
  288.     IF ¬ GENERATINGCFM THEN
  289.         Macro
  290.         _SetThreadSwitcher
  291.             move.w    #$070A,d0
  292.             dc.w     $ABF2
  293.         EndM
  294.     ELSE
  295.         IMPORT_CFM_FUNCTION    SetThreadSwitcher
  296.     ENDIF
  297.  
  298. ;
  299. ; pascal OSErr SetThreadTerminator(ThreadID thread, ThreadTerminationProcPtr threadTerminator, void *terminationProcParam)
  300. ;
  301.     IF ¬ GENERATINGCFM THEN
  302.         Macro
  303.         _SetThreadTerminator
  304.             move.w    #$0611,d0
  305.             dc.w     $ABF2
  306.         EndM
  307.     ELSE
  308.         IMPORT_CFM_FUNCTION    SetThreadTerminator
  309.     ENDIF
  310.  
  311. ;
  312. ; pascal OSErr ThreadBeginCritical(void)
  313. ;
  314.     IF ¬ GENERATINGCFM THEN
  315.         Macro
  316.         _ThreadBeginCritical
  317.             move.w    #$000B,d0
  318.             dc.w     $ABF2
  319.         EndM
  320.     ELSE
  321.         IMPORT_CFM_FUNCTION    ThreadBeginCritical
  322.     ENDIF
  323.  
  324. ;
  325. ; pascal OSErr ThreadEndCritical(void)
  326. ;
  327.     IF ¬ GENERATINGCFM THEN
  328.         Macro
  329.         _ThreadEndCritical
  330.             move.w    #$000C,d0
  331.             dc.w     $ABF2
  332.         EndM
  333.     ELSE
  334.         IMPORT_CFM_FUNCTION    ThreadEndCritical
  335.     ENDIF
  336.  
  337. ;
  338. ; pascal OSErr SetDebuggerNotificationProcs(DebuggerNewThreadProcPtr notifyNewThread, DebuggerDisposeThreadProcPtr notifyDisposeThread, DebuggerThreadSchedulerProcPtr notifyThreadScheduler)
  339. ;
  340.     IF ¬ GENERATINGCFM THEN
  341.         Macro
  342.         _SetDebuggerNotificationProcs
  343.             move.w    #$060D,d0
  344.             dc.w     $ABF2
  345.         EndM
  346.     ELSE
  347.         IMPORT_CFM_FUNCTION    SetDebuggerNotificationProcs
  348.     ENDIF
  349.  
  350. ;
  351. ; pascal OSErr GetThreadCurrentTaskRef(ThreadTaskRef *threadTRef)
  352. ;
  353.     IF ¬ GENERATINGCFM THEN
  354.         Macro
  355.         _GetThreadCurrentTaskRef
  356.             move.w    #$020E,d0
  357.             dc.w     $ABF2
  358.         EndM
  359.     ELSE
  360.         IMPORT_CFM_FUNCTION    GetThreadCurrentTaskRef
  361.     ENDIF
  362.  
  363. ;
  364. ; pascal OSErr GetThreadStateGivenTaskRef(ThreadTaskRef threadTRef, ThreadID threadToGet, ThreadState *threadState)
  365. ;
  366.     IF ¬ GENERATINGCFM THEN
  367.         Macro
  368.         _GetThreadStateGivenTaskRef
  369.             move.w    #$060F,d0
  370.             dc.w     $ABF2
  371.         EndM
  372.     ELSE
  373.         IMPORT_CFM_FUNCTION    GetThreadStateGivenTaskRef
  374.     ENDIF
  375.  
  376. ;
  377. ; pascal OSErr SetThreadReadyGivenTaskRef(ThreadTaskRef threadTRef, ThreadID threadToSet)
  378. ;
  379.     IF ¬ GENERATINGCFM THEN
  380.         Macro
  381.         _SetThreadReadyGivenTaskRef
  382.             move.w    #$0410,d0
  383.             dc.w     $ABF2
  384.         EndM
  385.     ELSE
  386.         IMPORT_CFM_FUNCTION    SetThreadReadyGivenTaskRef
  387.     ENDIF
  388.  
  389.     ENDIF ; __THREADS__
  390.